#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- mode: python -*-

import sys
from wsgiref.handlers import CGIHandler

class MyCGIHandler(CGIHandler):
  def log_exception(self,exc_info):
    import traceback

    self.error_body = '%s\n%s\n%s' % (exc_info[0], exc_info[1], '\n'.join(traceback.format_tb(exc_info[2])))

try:
  from twictures import handler
  MyCGIHandler().run(handler)
except:
  import traceback

  print 'Content-type: text/html'
  print
  print '<pre>Ooops.</pre>'
  print '<pre>%s\n%s\n' % (sys.exc_info()[0], sys.exc_info()[1])
  print '%s</pre>' % ('\n'.join(traceback.format_stack()))
